﻿using JGSY.SerialCommunication.UpperComputer.Core;
using JGSY.SerialCommunication.UpperComputer.Core.AOP;
using JGSY.SerialCommunication.UpperComputer.Core.AOP.AspectCore;
using JGSY.SerialCommunication.UpperComputer.Core.AOP.ThirdPartyLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace JGSY.SerialCommunication.UpperComputer
{
    public class Demo
    {
    }
    /// <summary>
    /// 1业务接口
    /// </summary>
    public interface IBankServes
    {
        void TarnsferMoney(decimal amount);
    }
    /// <summary>
    /// 2业务实现  【标记+Castle IInterceptableFlag】
    /// </summary>
    public class BankServes : IBankServes, IInterceptableFlag
    {
        [LogAspectDNC]

        [LogFlag]

        [LogCastleDynamicProxy]
        [ExceptionCastleDynamicProxy]
        public  void TarnsferMoney(decimal amount)
        {
            if (amount <= 0)
            {
                throw new ArgumentException("金额必须大于0");
            }

            Console.WriteLine($"转账成功：{amount}元");
        }
        
        public virtual void TarnsferMoney2(decimal amount)
        {
            if (amount <= 0)
            {
                throw new ArgumentException("金额必须大于0");
            }

            Console.WriteLine($"转账成功：{amount}元");
        }
    }
}
